#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START vim
# depends: cross-pkg-config
# depends: ncurses

rm -rf build/vim
# XXX: no out-of-the-source build
cp -a vim build/
cd build/vim

echo '#define SYS_VIMRC_FILE "/etc/vim/vimrc"' >> src/feature.h
cat > src/auto/config.cache <<-EOF
vim_cv_getcwd_broken=no
vim_cv_toupper_broken=no
vim_cv_terminfo=yes
vim_cv_tgetent=zero
vim_cv_stat_ignores_slash=no
vim_cv_memmove_handles_overlap=yes
EOF

./configure \
	${CONFIGURE_ARGS} \
	--with-tlib=tinfo \
	${AUTOCRAP_KLUDGE}

make -j${JOBS}
make -j${JOBS} STRIP=':' DESTDIR="$stage" install
ln -sf vim "${stage}${prefix}/bin/vi"
mkdir -p -m755 "$stage/etc/vim"
cat > "$stage/etc/vim/vimrc" <<-EOF
let skip_defaults_vim=1
set nocompatible
set backspace=2
syntax on
EOF
cd ../..
rm -rf build/vim

# RECIPE END vim
